<?php 
header('content-type:text/html;charset=utf-8');
try{
	$pdo=new PDO('mysql:host=localhost;dbname=imooc','root','root');
	//exec():鎵ц涓�潯sql璇彞骞惰繑鍥炲叾鍙楀奖鍝嶇殑璁板綍鐨勬潯鏁�濡傛灉娌℃湁鍙楀奖鍝嶇殑璁板綍锛屼粬杩斿洖0
	//exec瀵逛簬select娌℃湁浣滅敤
//	$sql=<<<EOF
//	INSERT user(username,password,email) VALUES("king1","king1","imooc1@qq.com"),
//	("king2","king2","imooc1@qq.com"),
//	("king3","king2","imooc1@qq.com")
//	
//EOF;
	//echo $sql;
	$sql='INSERT user(username,password,email) VALUES("king6","king6","imooc6@qq.com")';
	$res=$pdo->exec($sql);
	echo '鍙楀奖鍝嶇殑璁板綍鐨勬潯鏁颁负锛�.$res.'<br>';
	//$pdo->lastInsertId():寰楀埌鏂版彃鍏ヨ褰曠殑ID鍙�
	echo '鏈悗鎻掑叆鐨処鍙蜂负'.$pdo->lastInsertId();
}catch(PDOException $e){
	echo $e->getMessage();
}